//
//  HideNaviController.m
//  QKManager
//
//  Created by ukongm on 17/8/12.
//  Copyright © 2017年 ukongm. All rights reserved.
//

#import "HideNaviController.h"

@interface HideNaviController ()


@end

@implementation HideNaviController
#pragma mark ========================懒加载区======================
- (MYNaviView *)naviView{
    
    if (_naviView == nil) {
        _naviView = [[MYNaviView alloc] init];
    }
    return _naviView;
}
#pragma mark ========================自定义数据区======================
#pragma mark ========================UI区======================
- (void)_addLayout{
    
    typeof(self)sself = self;
    
    
    [self.naviView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.left.right.equalTo(sself.view);
        make.height.mas_equalTo(64);
    }];
    
}
#pragma mark ========================生命周期区======================
- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.naviView];
    
    [self _addLayout];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [self.navigationController setNavigationBarHidden:YES animated:YES];
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    
    [self.navigationController setNavigationBarHidden:NO animated:YES];
}


-(UIStatusBarStyle)preferredStatusBarStyle{
    return UIStatusBarStyleLightContent;
}
#pragma mark ========================请求数据区（包括请求代理）======================
#pragma mark ========================自定义事件区======================
- (void)resumeNaviView{
    
    [self.view bringSubviewToFront:self.naviView];
    
}
#pragma mark ========================代理区======================


#pragma mark ========================重写区======================
- (void)setTitle:(NSString *)title{
    self.naviView.title = title;
}


#pragma mark - 导航相关
- (void)navigationLeftItemTitle:(NSString*)title image:(NSString*)imageName
                         target:(id)target action:(SEL)action{
    
    [self navigationLeftItemTitle:title image:imageName target:target action:action frame:CGRectMake(0, 0, 30, 30)];
}

- (void)navigationRightItemTitle:(NSString*)title image:(NSString*)imageName
                          target:(id)target action:(SEL)action{
    
    [self navigationRightItemTitle:title image:imageName target:target action:action frame:CGRectMake(0, 0, 30, 30)];
}

- (void)navigationRightItemTitle:(NSString*)title image:(NSString*)imageName
                          target:(id)target action:(SEL)action frame:(CGRect)frame{
    [self navigationItemTitle:title image:imageName target:target action:action frame:frame left:NO];
}

- (void)navigationLeftItemTitle:(NSString*)title image:(NSString*)imageName
                         target:(id)target action:(SEL)action frame:(CGRect)frame{
    
    [self navigationItemTitle:title image:imageName target:target action:action frame:frame left:YES];
}

- (void)navigationItemTitle:(NSString*)title image:(NSString*)imageName
                     target:(id)target action:(SEL)action frame:(CGRect)frame left:(BOOL)left{
    
    UIButton* button = [[UIButton alloc] initWithFrame:frame];
    
    button.titleLabel.font = [UIFont systemFontOfSize:14];
    
    if (title) {
        [button setTitle:title forState:UIControlStateNormal];
    }
    
    if (imageName) {
        [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    }
    
    if (target && action) {
        
        [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    }
    
    UIButton* item = button;
    
    if (left) {
        [self navigationLeftItem:item rightItem:nil];
    }else{
        [self navigationLeftItem:nil rightItem:item];
    }
}

- (void)navigationRightItem:(UIButton*)rightItem{
    [self navigationLeftItem:nil rightItem:rightItem];
}

- (void)navigationLeftItem:(UIButton*)leftItem{
    [self navigationLeftItem:leftItem rightItem:nil];
}

- (void)navigationLeftItem:(UIButton*)leftItem rightItem:(UIButton*)rightItem{
    NSArray* leftItemArray = nil;
    NSArray* rightItemArray = nil;
    if (leftItem) {
        leftItemArray = @[leftItem];
    }
    
    if (rightItem) {
        rightItemArray = @[rightItem];
    }
    
    [self navigationLeftItems:leftItemArray rightItems:rightItemArray];
}

- (void)navigationRightItems:(NSArray<UIButton*>*)rightItems{
    [self navigationLeftItems:nil rightItems:rightItems];
}

- (void)navigationLeftItems:(NSArray<UIButton*>*)leftItems{
    
    [self navigationLeftItems:leftItems rightItems:nil];
    
}

- (void)navigationLeftItems:(NSArray<UIButton*>*)leftItems rightItems:(NSArray<UIButton*>*)rightItems{
    
    if (leftItems) {
        self.naviView.leftBtns = leftItems;
    }
    
    if (rightItems) {
        self.naviView.rightBtns = rightItems;
    }
}




@end
